Skip to content

Conversation

@mmagician
Copy link
Contributor

uses pipe_words_to_memory, but first ensures padding up to a number of felts divisible by 4.

This should be merged only after #2262 (comment) is addressed and we verify that this code still returns the expected value (it should!)

Comment on lines +30 to +31
push.LEAF_DATA_START_PTR push.LEAF_DATA_NUM_WORDS
exec.mem::pipe_words_to_memory dropw dropw dropw drop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function looks great! I added some stack comments, I think it should look like this:

pub proc get_leaf_value
    adv.push_mapval dropw
    # => [LEAF_DATA_KEY]

    push.LEAF_DATA_START_PTR push.LEAF_DATA_NUM_WORDS
    exec.mem::pipe_words_to_memory dropw dropw dropw drop
    # => []

    push.LEAF_DATA_BYTES push.LEAF_DATA_START_PTR
    # => [start_ptr, byte_len]

    exec.keccak256::hash_bytes
    # => [LEAF_VALUE[8]]

    # truncate stack
    swapdw dropw dropw
    # => [LEAF_VALUE[8]]
end

@partylikeits1983 partylikeits1983 self-requested a review January 14, 2026 17:53
Copy link
Contributor

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! My implementation was a bit complex, this is much better :)

@partylikeits1983 partylikeits1983 merged commit f9f2d57 into 0xMiden:ajl-agglayer-get-leaf-value Jan 14, 2026
15 of 16 checks passed
@mmagician mmagician deleted the mmagician-get-leaf-simplification branch January 14, 2026 20:24
@mmagician mmagician added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants